#ifndef __KYO_BUTTON_H__
#define __KYO_BUTTON_H__

#include <sdl.h>

typedef void (button_handle_t)(void *data);

struct button_t {
    SDL_Surface *button;            //按钮图片
    button_handle_t *handle;        //按钮触发函数
    void *data;                     //按钮触发函数的参数
    int x;                          //按钮显示的初始位置
    int y;
    int sw;                       //开/关按钮
    struct sdl_t *sdl;          
    int id;                         
    int free;                       //是否要销毁button图片
};

#define BUTTON_OFF      1
#define BUTTON_ON       0

struct button_t *button_create(struct sdl_t *sdl, SDL_Surface *pic, button_handle_t *handle, void *data);
struct button_t *button_create_txt(struct sdl_t *sdl, TTF_Font *font, const char *text, int color, button_handle_t *handle, void *data);
struct button_t *button_create_img(struct sdl_t *sdl, const char *path, button_handle_t *handle, void *data);
void button_show(struct button_t *button, int x, int y);
void button_set(struct button_t *button, int flag);
void button_destroy(struct button_t *);

#endif /* __KYO_BUTTON_H__ */

